package cn.ijero.floatwindow

import android.content.res.Resources
import android.util.TypedValue

val Number.dpInt: Int
    get() = dp().toInt()

val Number.spInt: Int
    get() = sp().toInt()

val Number.dp: Float
    get() = dp()

val Number.sp: Float
    get() = sp()

fun Number.dp(): Float {
    return TypedValue.applyDimension(
        TypedValue.COMPLEX_UNIT_DIP,
        this.toFloat(),
        Resources.getSystem().displayMetrics
    )
}

fun Number.sp(): Float {
    return TypedValue.applyDimension(
        TypedValue.COMPLEX_UNIT_SP,
        this.toFloat(),
        Resources.getSystem().displayMetrics
    )
}